<?php include "../public/header.php"?>
<?php include "../public/header_public.php"?>
<body class="laytp-container">
<div style="height: 45px" class="tthide"></div>
<div id="opt_nav">
</div>
<div id="dialog" class="tthide">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">选择待收取快递费</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <button class="layui-btn layui-btn-sm btn-dark marginr5" type="button" id="submit">确定</button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var tthide = getQueryVariable('tthide') || 0;
    if(tthide > 0){
        $(".tthide").remove();
    }

    // 单选多选分类 默认单选 choose_type传值为多选
    var choose_type = getQueryVariable('choose_type');
    if(choose_type === undefined || choose_type === false){
        choose_type = 'radio';
    }else{
        choose_type = 'checkbox';
    }

    var parent_dom = getQueryVariable('dom');
    var parent_page = getQueryVariable('page');
    var parent_enginid = getQueryVariable('enginid') || 0;
    var parent_gofuer = decodeURI(getQueryVariable('gofuer') || '') || '';
    var parent_daodt = decodeURI(getQueryVariable('daodt') || '') || '';


    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        $("#cols_table").hide();
        $("#export_table").hide();
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_koulei_kuaifei_list),where: {enginid:parent_enginid,gofuer:parent_gofuer,daodt:parent_daodt}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: ['', '', ''],filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,parseData: function(res){

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            ,cols: [[
                {type: choose_type, fixed: 'left'}
                ,{type: 'numbers',title:'序号',fixed:'left'}
                ,{field: 'enginname', title: '工程名称'}
                ,{field: 'kuailei', title: '收寄类型'}
                ,{field: 'yunnum', title: '运单号'}
                ,{field: 'kuaidt', title: '收寄日期'}
                ,{field: 'futype', title: '付款方式'}
                ,{field: 'kuaifee', title: '快递费用(元)'}
                ,{field: 'kouxing', title: '收取状态'}
            ]]
            ,done : function(res, curr, count){
                $(".layui-table-tool").remove()
                soulTable.render(this);
            }
        });
        listTableSearch(form, table);


        $('#submit').on('click', function () {
            var checkStatus = layui.table.checkStatus('datalist');
            var data = checkStatus.data;
            if(data.length < 1){
                facade.error("请选择数据");return false;
            }

            if(parent_page == 'hou_gonghui'){
                var str = '';
                var numkeyss = $("#kuaifei_list tr", parent.document).length;
                for (var key in data){
                    numkeyss++;
                    str += '<tr>';
                    str += '<td style="width: 45px">'+numkeyss+'</td>';
                    str += '<td><input type="text" readonly houkoulei="4" value="快递费" class="layui-input houkoulei disabled"></td>';
                    str += '<td><input type="text" readonly kuaitype="'+data[key].kuaitype+'" kuaiid="'+data[key].id+'" value="'+data[key].enginname+'" class="layui-input enginname disabled"></td>';

                    str += '<td><input type="number" readonly value="'+data[key].kuaifee+'" class="layui-input koufee disabled"></td>';
                    str += '<td><input type="text" class="layui-input disabled kouxing" value="实扣" readonly></td>';
                    str += '<td><input type="text" class="layui-input shoubiao"></td>';
                    str += '<td><input type="text" class="layui-input explain"></td>';

                    str += '<td><input type="text" readonly value="'+data[key].kuailei+'" class="layui-input kuailei disabled"></td>';
                    str += '<td><input type="text" readonly value="'+data[key].yunnum+'" class="layui-input yunnum disabled"></td>';
                    str += '<td><input type="text" readonly value="'+data[key].kuaidt+'" class="layui-input kuaidt disabled"></td>';
                    str += '<td><input type="text" readonly value="'+data[key].futype+'" class="layui-input futype disabled"></td>';
                    str += '<td><input type="number" readonly value="'+data[key].kuaifee+'" class="layui-input kuaifee disabled"></td>';
                    str += '<td><input type="text" readonly value="未收取" class="layui-input disabled"></td>';

                    str += '</tr>';
                }
                $("#kuaifei_list", parent.document).append(str);
                if (typeof(window.parent.update_refresh_row_func)!="undefined"){
                    window.parent.update_refresh_row_func();
                }
            }else{
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].number+'('+data[0].money+')' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                parent.formValid(parent_dom);

            }

            layer_close();
        });

    });
</script>
</body>
</html>
